﻿using System;

namespace DebIt.Common.Model
{
    public class LoanItem : DbStoredItem
    {
        #region variables

        private Loan _loan;
        private string _description;
        private decimal _value;
        
        #endregion


        #region properties

        public int LoanItemId { get; set; }

        public Loan Loan
        {
            get { return _loan; }
            set
            {
                if (_loan == value) return;
                SendPropertyChanging(() => Loan);
                _loan = value;
                SendPropertyChanged(() => Loan);
            }
        }

        public string Description
        {
            get { return _description; }
            set
            {
                if (_description == value) return;
                SendPropertyChanging(() => Description);
                _description = value;
                SendPropertyChanged(() => Description);
            }
        }

        public decimal Value
        {
            get { return _value; }
            set
            {
                if (_value == value) return;
                SendPropertyChanging(() => Value);
                _value = Math.Round(value, 2);
                SendPropertyChanged(() => Value);
            }
        }

        #endregion

    }
}
